package com.slz3.business.module.messageManagement.mesLog.steward;

import com.slz3.business.frame.response.RR;
import com.slz3.business.frame.response.ResInfo;
import com.slz3.business.module.messageManagement.mesLog.domain.MesLog;
import com.slz3.business.module.messageManagement.mesLog.domain.MesLogCondition;
import org.springframework.stereotype.Controller;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

import javax.annotation.Resource;

@Controller
public class MesLogResController {

    @Resource
    private MesLogResAtomic mesLogResAtomic;

    public Mono<ServerResponse> add(ServerRequest req, MesLog mesLog) {
        if (MesLogResUnsafeValid.add(req, mesLog)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesLogResAtomic.add_$MesLogUpdateLock(req, mesLog);
        }
    }

    public Mono<ServerResponse> delete(ServerRequest req, MesLogCondition mesLogCondition) {
        if (MesLogResUnsafeValid.delete(req, mesLogCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesLogResAtomic.delete_$MesLogUpdateLock(req, mesLogCondition);
        }
    }

    public Mono<ServerResponse> modify(ServerRequest req, MesLog mesLog) {
        if (MesLogResUnsafeValid.modify(req, mesLog)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesLogResAtomic.modify_$MesLogUpdateLock(req, mesLog);
        }
    }

    public Mono<ServerResponse> list(ServerRequest req) {
        if (MesLogResUnsafeValid.list(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return MesLogResExecutor.list(req);
        }
    }

    public Mono<ServerResponse> info(ServerRequest req) {
//        return mesLogResAtomic.info_$MesLogUpdateLock(req);
        if (MesLogResUnsafeValid.info(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesLogResAtomic.info_$MesLogUpdateLock(req);
        }
    }

    public Mono<ServerResponse> choice(ServerRequest req) {
        if (MesLogResUnsafeValid.choice(req)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return MesLogResExecutor.choice(req);
        }
    }

    public Mono<ServerResponse> auditSubmit(ServerRequest req, MesLogCondition mesLogCondition) {
        //
        if (MesLogResUnsafeValid.auditSubmit(req, mesLogCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesLogResAtomic.auditSubmit_$MesLogUpdateLock(req, mesLogCondition);
        }
    }

    public Mono<ServerResponse> audit(ServerRequest req, MesLogCondition mesLogCondition) {
        if (MesLogResUnsafeValid.audit(req, mesLogCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesLogResAtomic.audit_$MesLogUpdateLock(req, mesLogCondition);
        }
    }

    public Mono<ServerResponse> auditReject(ServerRequest req, MesLogCondition mesLogCondition) {
        if (MesLogResUnsafeValid.auditReject(req, mesLogCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesLogResAtomic.auditReject_$MesLogUpdateLock(req, mesLogCondition);
        }
    }

    public Mono<ServerResponse> usingEnable(ServerRequest req, MesLogCondition mesLogCondition) {
        if (MesLogResUnsafeValid.usingEnable(req, mesLogCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesLogResAtomic.usingEnable_$MesLogUpdateLock(req, mesLogCondition);
        }
    }

    public Mono<ServerResponse> usingDisable(ServerRequest req, MesLogCondition mesLogCondition) {
        if (MesLogResUnsafeValid.usingDisable(req, mesLogCondition)) {
            return RR.error(req, ResInfo.builder().theme(RR.UN_SAFE_VALID).description(RR.ILLEGAL_PARAM).build());
        } else {
            return mesLogResAtomic.usingDisable_$MesLogUpdateLock(req, mesLogCondition);
        }
    }

}
